package com.ruoyi.web.studentmanagementsystem.service.impl;

import com.ruoyi.web.studentmanagementsystem.dto.*;
import com.ruoyi.web.studentmanagementsystem.pojo.SysStudent;
import com.ruoyi.web.studentmanagementsystem.mapper.SysStudentMapper;
import com.ruoyi.web.studentmanagementsystem.service.ISysStudentService;
import com.ruoyi.web.studentmanagementsystem.vo.SysStudentVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * ClassName: SysStudentServiceImpl
 * Package: com.ruoyi.web.studentmanagementsystem.service.impl
 * Description:学生管理 服务实现
 *
 * @Author Mr. o
 * @Create 2023/11/8 10:40
 * @Version 1.0
 */
@Service
public class SysStudentServiceImpl implements ISysStudentService
{
    @Resource
    private SysStudentMapper studentMapper;



    /**
     * 新增保存学生信息
     *
     * @param student 学生信息
     * @return
     */
    @Override
    @Transactional
    public void insertStudent(ISysStudentDTO student) {
        student.setCreateTime(new Date());
        studentMapper.insertStudent(student);
    }

    /**
     * 删除学生信息
     *
     * @param studentId 学生ID
     * @return
     */
    @Override
    @Transactional
    public void deleteStudentId(String studentId) {
        studentMapper.deleteStudentId(studentId);
    }

    /**
     * 根据学生姓名查询信息
     *
     * @param studentName 学生姓名
     * @return
     */
    @Override
    @Transactional
    public List<SysStudent> selectStudentName(String studentName) {
        return studentMapper.selectStudentName(studentName);
    }

    /**
     * 修改保存学生信息
     *
     * @param student 学生信息
     * @return
     */
    public void updateStudent(IISysStudentDTO student) {
        student.setUpdateTime(new Date());
        studentMapper.updateStudent(student);
    }

    /**
     * 查询所有学生
     * @param
     * @return
     */
    public List<SysStudentVO> selectStudentAll() {
        return studentMapper.selectStudentAll();
    }

    /**
     * 查询所有学生(Id)
     * @param
     * @return
     */
    public List<SysStudentVO> selectStudentAllId(String studentId) {
        return studentMapper.selectStudentAllId(studentId);
    }
}
